package com.wash.ctrl.goods;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wash.framework.utils.JsonUtil;
import com.wash.model.Goods;
import com.wash.service.GoodsService;

@Lazy(true)
@Controller
@RequestMapping
public class GoodsCtrl {

	@Autowired
	private GoodsService goodsService;
	
	/**
	 * 
	 * @return
	 */
	@RequestMapping
	@ResponseBody
	public String listGoods(Goods goods) {
		List<Goods> lst=goodsService.getGoods(goods);
		return JsonUtil.writeObject(lst);
	}
	
	/**
	 * 添加商品
	 * @param g
	 * @return
	 */
	@RequestMapping
	@ResponseBody
	public String add(Goods g) {
		return goodsService.addGoods(g);
	}
	
	/**
	 * 修改商品
	 * @param g
	 * @return
	 */
	@RequestMapping
	@ResponseBody
	public String edit(Goods g){
		return goodsService.editGoods(g);
	}
	
	/**
	 * 删除商品
	 * @param id
	 * @return
	 */
	@RequestMapping
	@ResponseBody
	public String dele(int id){
		return goodsService.deleGoods(id);
	}
}
